Python for Unix and Linux system administration by Noah Gift; Jeremy Jones
Author:Noah Gift; Jeremy Jones
Language: eng
Format: mobi, pdf
Tags: JavaScript, Networking, Programming Languages, Reference:Computers, Electronic books, Computers, Programming, General, Intranets & Extranets, UNIX, UNIX (Computer file), Linux, Python (Computer program language), Python, Operating Systems
ISBN: 9780596515829
Publisher: Farnham : O'Reilly, 2008.
Published: 2008-01-15T08:58:04.918000+00:00
"""Returns Hit Count for Firefox"""
def grep(lines,pattern="Firefox"):
pat = re.compile(pattern)
for line in lines:
if pat.search(line): yield line
def increment(lines):
num = 0
for line in lines:
num += 1
return num
wwwlog = open("/home/noahgift/logs/noahgift.com-combined-log")
column = (line.rsplit(None,1)[1] for line in wwwlog)
match = grep(column)
count = increment(match)
print "Total Number of Firefox Hits: %s" % count
In order for our query to work in the first place, we needed to tell snmpd.conf about this script, and here is what that section looks like:
syslocation "O'Reilly"
syscontact [email protected]
rocommunity public
exec helloworld /usr/bin/python -c "print 'hello world from Python'"
exec .1.3.6.1.4.1.2021.28664.100 FirefoxHits /usr/bin/python
/opt/local/snmp_scripts/agent_ext_logs.py
The magic portion is the last line, in which .1.3.6.1.4.1.2021 is the ucdavis enterprise number, 28664 our enterprise number, and 100 is some contrived value that we decided we wanted to use. It is really important to follow best practices and use your our enterprise number if you plan on extending SNMP. The main reason is that you will avoid causing havoc if you decide to use a range already occupied by someone else and then make changes via snmpset.
We would like to close with the fact that this is one of the more exciting topics in the book, and SNMP is still a very untouched playground. There are many things that customizing Net-SNMP can be useful for, and if you are careful to use SNMP v3, you can do some incredible things that are most easily accomplished through the SNMP protocol; and that ssh or sockets would be the most natural choice.
Download
Python for Unix and Linux system administration by Noah Gift; Jeremy Jones.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
ActiveX | ASP.NET |
Cold Fusion | CSS |
DHTML | Java Server Pages |
JavaScript | PHP |
Python | Ruby |
XSL |
Hello! Python by Anthony Briggs(9867)
The Mikado Method by Ola Ellnestam Daniel Brolund(9747)
Dependency Injection in .NET by Mark Seemann(9293)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7745)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7517)
Svelte with Test-Driven Development by Daniel Irvine(6846)
Test-Driven Development with PHP 8 by Rainier Sarabia(6563)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6512)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(6431)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6378)
Web Development with Django by Ben Shaw Saurabh Badhwar(5882)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5783)
React Application Architecture for Production by Alan Alickovic(5624)
Kotlin in Action by Dmitry Jemerov(5019)
Audition by Ryu Murakami(4555)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4297)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4284)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4134)
Functional Programming in JavaScript by Mantyla Dan(4018)
